#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QUdpSocket>
#include <QTimer>
#include <QProcess>
#include <QProgressBar>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QTextEdit>
#include <QRadioButton>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_startConnectButton_clicked();
    void on_pingTimer_timeout();
    void on_startRegistrationButton_clicked();
    void on_sendButton_clicked();
    void readPendingDatagrams();
    void checkRegistrationTimeout();
    void checkSendTimeout();
    void on_pingProcess_finished(int exitCode, QProcess::ExitStatus exitStatus);

private:
    Ui::MainWindow *ui;
    QUdpSocket *udpSocket;
    QTimer *pingTimer;
    QTimer *registrationTimer;
    QTimer *sendTimer;
    QProcess *pingProcess;
    QProgressBar *progressBar;
    QLabel *registrationFailureLabel;
    QLabel *sendFailureLabel;
    QLineEdit *ipPart1Edit;
    QLineEdit *ipPart2Edit;
    QLineEdit *ipPart3Edit;
    QLineEdit *ipPart4Edit;
    QLineEdit *portLineEdit;
    QPushButton *startConnectButton;
    QPushButton *startRegistrationButton;
    QPushButton *sendButton;
    QTextEdit *receiveTextEdit;
    QTextEdit *sendTextEdit;
    QRadioButton *asciiRadioButton;
    QRadioButton *binaryRadioButton;
    int registrationFailureCount;
    int sendFailureCount;
    bool registrationInProgress;
    bool sendInProgress;
    QString getFullIP();
};
#endif // MAINWINDOW_H
